import { request } from "@/utils/service"
import { Menu } from "./types/menu"
import { PageData } from "types/pageData"
import { MenuQuery } from "./types/menuQuery"
export async function getUserMenu(): Promise<ApiResponseData<Menu[]>> {
  return request<ApiResponseData<Menu[]>>({
    url: "/api/menuinfo/GetMenuByUser",
    method: "get"
  })
}
export async function getLazyList(query: MenuQuery): Promise<ApiResponseData<PageData<Menu>>> {
  return request<ApiResponseData<PageData<Menu>>>({
    url: "api/menuinfo/GetLazyList",
    method: "get",
    params: query
  })
}

export async function getMenuTree(): Promise<ApiResponseData<Menu[]>> {
  return request<ApiResponseData<Menu[]>>({
    url: "/api/menuinfo/GetMenuTree",
    method: "get"
  })
}

export async function create(data: Menu): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/menuinfo/Create",
    method: "post",
    data: data
  })
}

export async function update(data: Menu): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/menuinfo/Update",
    method: "post",
    data: data
  })
}
export async function del(params: any): Promise<ApiResponseData<boolean>> {
  return request<ApiResponseData<boolean>>({
    url: "/api/menuinfo/Delete",
    method: "get",
    params: params
  })
}
export async function getMenuByRoleId(params: any): Promise<ApiResponseData<number[]>> {
  return request<ApiResponseData<number[]>>({
    url: "/api/menuinfo/GetMenuByRoleId",
    method: "get",
    params: params
  })
}
